﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Web.Security;
using BusinessLogic;

namespace DataAccessLogic
{
    public static class CountryDataAccess
    {
        #region Methods
        public static Country BindDataToCountry(DataRow row)
        {
            return FormattedCodeTableDataAccess.BindRowToFormattedCodeTable<Country>(row);
        }

        public static Guid Create(Country country)
        {
            Guid id = Guid.Empty;

            if(country != null)
            {
                id = FormattedCodeTableDataAccess.Create(StoredProcedures.USP_COUNTRYFORMATTEDTYPECODE_CREATE, country.Description, country.Abbreviation);
            }

            return id;
        }

        public static void Delete(Country country)
        {
            Delete(country.ID);
        }

        public static void Delete(Guid id)
        {
            FormattedCodeTableDataAccess.Delete(StoredProcedures.USP_COUNTRYFORMATTEDTYPECODE_DELETE, id);
        }

        public static DataTable GetAll()
        {
            return FormattedCodeTableDataAccess.GetAll(StoredProcedures.USP_COUNTRYFORMATTEDTYPECODE_GETALL);
        }

        public static DataRow GetByID(Guid id)
        {
            return FormattedCodeTableDataAccess.GetByID(StoredProcedures.USP_COUNTRYFORMATTEDTYPECODE_GETBYID, id);
        }
        #endregion
    }
}